package controller.algorithms;

import java.util.ArrayList;

import utilities.clock.Clock;
import utilities.clock.ClockListener;

import controller.entitiesManagement.Entity;
import controller.taskManagement.Task;

public class OverviewManager implements ClockListener {
	private static OverviewManager m_overviewManager;
	private ArrayList<EntityTaskBet> m_values;
	private Clock m_clock;
	
	private OverviewManager(){
		m_values = new ArrayList<EntityTaskBet>();
		m_clock = Clock.getClock();
		m_clock.addClockListener(this);
	}
	
	public static OverviewManager getInstance(){
		if(m_overviewManager==null)
			m_overviewManager = new OverviewManager();
		return m_overviewManager;
	}
	
	public void addValue(EntityTaskBet entityTaskBet){
		m_values.add(entityTaskBet);
	}
	
	public void addValue(Entity entity, Task task, double bet){
		m_values.add(new EntityTaskBet(entity, task, bet));
	}
	
	public void removeValue(EntityTaskBet entityTaskBet){
		m_values.remove(entityTaskBet);
	}
	
	public EntityTaskBet getBestBetOfEntity(Entity entity){
		if(m_values.isEmpty())
			return null;
		double bestBet = m_values.get(0).bet;
		EntityTaskBet bestValue = m_values.get(0);
		for(int i=1;i<m_values.size();i++){
			if(m_values.get(i).bet>bestBet){
				bestBet = m_values.get(i).bet;
				bestValue = m_values.get(i);
			}
		}
		return bestValue;
	}

	public void acts() {
		
	}

	public void setClock(Clock this_clock) {
		
	}
}
